package binaryTreeNode;

public class IsSymmetric {
    public static void main(String[] args) {
        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.right = new TreeNode(2);
        root.left.left = new TreeNode(3);
        root.left.right = new TreeNode(4);
        root.right.left = new TreeNode(4);
        root.right.right = new TreeNode(3);
        System.out.println(isSymmetric(root));
    }
    public static boolean isSymmetric(TreeNode root) {
        if(root==null)
            return true;
        return root.left==invertTree(root.right);
    }
    public static  TreeNode invertTree(TreeNode root) {
        TreeNode p=root,temp;
        if(root == null)
            return p;
        temp =p.right ;
        p.right= invertTree(root.left);
        p.left=invertTree(temp);
        return p;
    }
}
